package com.ghc.controller;

import com.ghc.service.AccountService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {
    private final AccountService accountService;

    @RequestMapping("/register/{email}/{password}/{code}")
    public int register(@PathVariable String email, @PathVariable String password, @PathVariable String code){
        return accountService.register(email, password, code);
    }

    @RequestMapping("/isRegistered/{email}")
    public Boolean isRegistered(@PathVariable String email){
        return accountService.isRegistered(email);
    }

    @RequestMapping("/login/{email}/{password}")
    public String login(@PathVariable String email, @PathVariable String password){
        return accountService.login(email, password);
    }

    @RequestMapping("/info/{token}")
    public String info(@PathVariable String token){
        return accountService.info(token);
    }
}
